package com.egao.orderB.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
import com.egao.orderB.biz.SettingsBiz;
import com.egao.orderB.entity.Settings;
import com.egao.orderB.service.SettingsService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

//import com.egao.orderB.mapper.SettingsMapper;
//import javax.transaction.Transactional;

/**
 * 设置服务实现类
 * @author : Doman
 * @date : 2020-12-16 16:28:34
 * @version ：1.0
 */
@Service
public class SettingsServiceImpl /*extends ServiceImpl<SettingsMapper, Settings> */implements SettingsService {

	@Autowired
	private SettingsBiz settingsBiz;

    /**
    @Override
    public PageResult<Settings> listPage(PageParam<Settings> page) {
        List<Settings> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<Settings> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, Settings settings, User loginUser)  throws Exception{
        return settingsBiz.list(page,settings,loginUser);
    }

    @Override
    public JsonResult list(Settings settings, User loginUser) {
        return JsonResult.ok().setData(settingsBiz.list(settings,loginUser));
    }

    @Override
    public JsonResult getById(Settings settings) {
        return JsonResult.ok().setData(settingsBiz.getById(settings));
    }

    @Override
    public JsonResult getByName(Settings settings) {
        return JsonResult.ok().setData(settingsBiz.getByName(settings));
    }

    @Override
    public JsonResult save(Settings settings, User loginUser) {
        if (settingsBiz.save(settings, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Override
    public JsonResult update(Settings settings, User loginUser) {
        if (settingsBiz.update(settings, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Override
    public JsonResult updateOilFee(Settings settings, User loginUser) {
        if (settingsBiz.updateOilFee(settings, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Override
    public JsonResult remove(Settings settings, User loginUser) {
        if (settingsBiz.remove(settings, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
